# 提供给AI模板生成的mcp server
from mcp.server.fastmcp import FastMCP
import datetime

# 创建一个 MCP 服务器
mcp = FastMCP("BeijingWeatherServer")

# 模拟北京天气数据
MOCK_WEATHER_DATA = {
    'city': '北京',
    'temperature': '25°C',
    'condition': '晴'
}

@mcp.tool()
def get_beijing_weather() -> dict:
    """获取北京当前时间和天气"""
    current_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
    return {
        'time': current_time,
        'weather': MOCK_WEATHER_DATA
    }

if __name__ == '__main__':
    # 这里只是示例，实际运行可能需要调整
    # import uvicorn
    # from fastapi import FastAPI
    # app = FastAPI()
    # app.mount("/mcp", mcp.app)
    # uvicorn.run(app, host='0.0.0.0', port=8000)
    print("Starting FastMCP server with 'weather' service...")
    mcp.run(transport='stdio')
    print("FastMCP server stopped.")
